<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="/Public/Admin/lib/html5.js"></script>
<script type="text/javascript" src="/Public/Admin/lib/respond.min.js"></script>
<script type="text/javascript" src="/Public/Admin/lib/PIE_IE678.js"></script>
<![endif]-->
<link rel="icon" href="/bitbug_favicon.ico" />
<link href="/Public/Admin/css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="/Public/Admin/css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="/Public/Admin/lib/icheck/icheck.css" rel="stylesheet" type="text/css" />
<link href="/Public/Admin/lib/Hui-iconfont/1.0.6/iconfont.css" rel="stylesheet" type="text/css" />
<link href="/Public/Admin/css/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="/Public/Admin/lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">

<!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->


<title>添加产品分类</title>
</head>
<body>
<div class="pd-20">
	<?php if(!empty($cat_id)): ?><a href="<?php echo U('categoryAdd',array('add'=>1,'cat_id'=>$cat_id));?>" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加子分类</a></span><?php endif; ?>
  <form action="" method="post" class="form form-horizontal" id="form-user-add">
  <div class="row cl">
      <label class="form-label col-2">上级分类名称：</label>
      <div class="formControls col-5">
        <input type="text" class="input-text" value="<?php if(empty($cat_id)): ?>第一级分类<?php else: echo ($p_name); endif; ?>" placeholder="" id="user-name" name="cat_name" readonly="readonly">
      </div>
      <div class="col-5"> </div>
    </div>
    <div class="row cl">
      <label class="form-label col-2"><span class="c-red">*</span>分类名称：</label>
      <div class="formControls col-5">
        <input type="text" class="input-text" value="<?php echo ($cat['cat_name']); ?>" placeholder="" id="user-name" name="cat_name">
      </div>
      <div class="col-5"> </div>
    </div>
    <div class="row cl">
      <label class="form-label col-2">排序：</label>
      <div class="formControls col-5">
        <input type="text" class="input-text" value="<?php if(empty($cat)): ?>0<?php else: echo ($cat['sort']); endif; ?>" placeholder="" id="user-name" name="sort">
      </div>
      <div class="col-5"> </div>
    </div>
    
    <div class="row cl">
      <div class="col-9 col-offset-2">
      	<?php if(!empty($cat)): ?><input type="hidden" name="cat_id" value="<?php echo ($cat_id); ?>"/><?php endif; ?>
      	<?php if($_GET['add'] == 1): ?><input type="hidden" name="pid" value="<?php echo ($cat_id); ?>"/><?php endif; ?>
        <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;<?php if(empty($cat)): ?>添加栏目<?php else: ?>修改栏目<?php endif; ?>&nbsp;&nbsp;">
        <?php if(!empty($cat)): ?><a class="btn btn-danger radius" onclick="member_del('<?php echo U('categoryDel',array('add'=>1,'cat_id'=>$cat_id));?>')"><i class="Hui-iconfont">&#xe6e2;</i> 删除分类</a></span><?php endif; ?>
      </div>
    </div>
  </form>
</div>
</div> 


<script type="text/javascript" src="/Public/Admin/lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="/Public/Admin/lib/icheck/jquery.icheck.min.js"></script> 
<script type="text/javascript" src="/Public/Admin/lib/Validform/5.3.2/Validform.min.js"></script>
<script type="text/javascript" src="/Public/Admin/lib/layer/2.1/layer.js"></script>
<script type="text/javascript" src="/Public/Admin/js/H-ui.js"></script> 
<script type="text/javascript" src="/Public/Admin/js/H-ui.admin.js"></script>
<script type="text/javascript" src="/Public/Admin/js/jquery.form.js"></script>
<script type="text/javascript">
$(function(){
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	
	var form = $("#form-user-add").Validform({
		url:'<?php echo U();?>',
		ajaxPost:true,
		callback:function(data){
			$.Hidemsg();
			if(data.status == 1){ // 成功
				
				$.Showmsg('成功');
				setTimeout(function (){
					$.Hidemsg();
					parent.location.reload();
				},1000);
			}else { // 失败
				$.Showmsg(data.msg);
				setTimeout(function (){
					$.Hidemsg();
				},1000);
			}
		}
	});
});

function member_del(url){
	layer.confirm('确认要删除吗？',function(index){
		
		$.post(url,{},function(data){
			if(data.status == 1){
				layer.msg('删除成功!',{icon:6,time:1000});
				setTimeout(function(){
					parent.location.reload();
				},1000);
			}else {
				layer.msg('删除失败!',{icon:5,time:1000});
			}
			
		})
	});
}
</script>
</body>


</html>